/*--------------------------------------------------------------------------------
 * 
 *
 * ===Copyright===
 * Copyright (C) 2008 toge (toge.mail@gmail.com)
 * (See Copyright Notice at COPYRIGHT file)
 *
 * ===Licence===
 * Mit License
 *
 * ===Revision===
 * $Revision: 117 $
 -------------------------------------------------------------------------------*/
#include "common.h"
#include "Constants.h"
#include "FrameClock.h"

#include <SDL.h>

using namespace ggl2d;

Constants *Constants::instance_ = 0;

static
unsigned int
keymap[12] = {SDLK_z, SDLK_x, SDLK_c, SDLK_v,
              SDLK_a, SDLK_s, SDLK_d, SDLK_f,
              SDLK_LSHIFT, SDLK_LCTRL, SDLK_SPACE, SDLK_ESCAPE};

static
unsigned char
butmap[12] = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u};

bool Constants::load()
{
  windowWidth_ = 800;
  windowHeight_ = 600;

  frameSize_  = Vector( 4096,  3072);
  stageSize_  = Vector(frameSize().x() * 9, frameSize().y() * 9);

  initLevel_      = 10;
  stageLevel_     = 20;
  substageLevel_  = 30;
  stageinfoLevel_ = 40;
  feedbackLevel_  = -21;
  textLevel_      = 50;
  textboxLevel_   = 60;
  fpsLevel_       = 70;
  updateLevel_    = 80;

  checkspan_ = FrameTime(0,  50 * 1000);

  objectTailNumber_ = 128;

  batterySize_      = Vector(50.f, 200.f);
  batteryNumber_    = 1000;               
  batteryFireSpan_  = 50.f;               
  batteryTailWidth_ = 24.f;               

  bulletSize_     = Vector(40.f, 40.f);
  bulletSize2_    = 24.f;              
  bulletSpeed_    = 1200.f;            
  bulletLifetime_ = 300.f;             

  playerSize_             = Vector(100.f, 100.f);                        
  playerSpeed_            = 3000.f;                                      
  playerAccel_            = 666.f;                                       
  playerDecl_             = 0.2f;                                        
  playerReflect_          = 0.5f;                                        
  playerBreak_            = 0.9995f;                                     
  playerTailWidth_        = 32.f;                                        
  playerStabSpan_         = FrameTime(0, FrameTime::MICROSECOND * 0.25);
  playerStabFreezeSpan_   = FrameTime(0, FrameTime::MICROSECOND * 0.5); 
  playerStabMaxVelocity_  = 7500.f;                                      
  playerBladeWidth_       = 25.f;                                        
  playerBladeMaxSize_     = 200.f;                                       
  playerTargetChangeSpan_ = FrameTime(10, 0);                            

  hoseiSpan_ = 0.6f;
  bboxRect_ = Rect(0, 0, 4096.f, 3072.f);
  hoseiSize_ = Vector(1638.4f, 1228.8f);

  positionMessage_     = "player(% 8.1f, % 8.1f)";
  positionMessageSize_ = 31;

  subwindowSize_ = Vector(409.6f, 307.2f);

  hoseiJoystick_ = 0.025f;
  joystickID_ = 1;

  keyboardMap_ = keymap;
  buttonMap_ = butmap;

  doubleClickSpan_ = FrameTime(0, FrameTime::MICROSECOND * 2 / 3);

  bulletBurstLifetime_ = 15.f;
  bulletBurstSize_     = 200.f;

  posteffectAlpha_ = 0.5f;

  vboSizeBullet_      = 1024;
  vboSizeBulletBurst_ = 1024;
  vboSizeBattery_     = 1024;

  return true;
}

